<template>
    <div>
        <TreeSelect v-model="value"
                    :multiple="multiple"
                    @on-change="selectChange"
                    show-checkbox
                    :data="dataList" />
    </div>
</template>
<script>
    import { GetCategoraySelect } from '@/api/components'
    export default {
        name: 'selectTree',
        props: {
            multiple: {
                type: Boolean,
                default: true
            },
            modelDate: {
                type: [String, Array]
            }
        },
        data () {
            return {
                dataList: [],
                value: []
            }
        },
        created () {
            this.getCategoraySelect();
            if (this.multiple) {
                let value = [...this.modelDate];
                this.value = value;
            } else {
                this.value = this.modelDate + ''
            }
        },
        methods: {
            getCategoraySelect () {
                let data = {}
                // 开始请求商品列表
                GetCategoraySelect(data).then(res => {
                    this.dataList = [...res.list]
                })
            },
            // 改变选中值
            selectChange (value) {
                this.$emit('changeSelectTreeModel', value)
            }
        }
    }
</script>
<style lang="less">
</style>
